package com.laboratory.exception;

import java.util.ArrayList;
import java.util.List;

public class TryCatchFinallyTest {

	public static void main(String[] args) {
//		System.out.println(ReturnTest());;
		deadLoopTest();
	}

	public static void deadLoopTest(){
		ArrayList arrayList = new ArrayList();
		try {
			while (true){
			List subList=	new ArrayList();
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				subList.add("GG");
				arrayList.addAll(subList);
			}
		}catch (Throwable e){
			System.out.println("catch run...");
			e.printStackTrace();
		}finally {
			System.out.println(arrayList.size()+ "finally run....");
		}



	}

	public static int ReturnTest(){
		int a=0,b=0;
		try {
			b=a+1;
			System.out.println("---"+b);
			int c=b / 2;
			return ++b;
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("catch run!");
			return ++b;
		}finally{
			System.out.println("finlly run!");
			return 10;
		}
	}

}
